package com.devicehive.resource;

/*
 * #%L
 * DeviceHive Java Server Common business logic
 * %%
 * Copyright (C) 2016 DataArt
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import com.devicehive.vo.ApiInfoVO;
import com.devicehive.vo.CacheInfoVO;
import com.devicehive.vo.ClusterConfigVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.security.access.prepost.PreAuthorize;

import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;

@Api(tags = {"ApiInfoVO"}, description = "API information", consumes = "application/json")
@Path("/info")
@Produces({"application/json"})
public interface ApiInfoResource {

    @GET
    @PreAuthorize("permitAll")
    @ApiOperation(value = "Get API info", notes = "Returns version of API, server timestamp and WebSocket base uri"
    )
    @ApiResponses(value = {
            @ApiResponse(code = 200,
                    message = "Returns version of API, server timestamp and WebSocket base uri",
                    response = ApiInfoVO.class),
    })
    Response getApiInfo(@Context UriInfo uriInfo,
                        @HeaderParam("X-Forwarded-Proto")
                        @DefaultValue("http")
                                String protocol);
    
    @GET
    @Path("/cache")
    @PreAuthorize("permitAll")
    @ApiOperation(value = "Get cache info", notes = "Returns cache info")
    @ApiResponses(value = {
            @ApiResponse(code = 200,
            message = "Returns cache info",
            response = CacheInfoVO.class),
    })
    Response getApiInfoCache(@Context UriInfo uriInfo);

    @GET
    @Path("/config/cluster")
    @PreAuthorize("permitAll")
    @ApiOperation(value = "Get cluster configuration", notes = "Returns information about cluster (Kafka, Zookeeper etc.)",
            response = ClusterConfigVO.class)
    @ApiResponses(value = {
            @ApiResponse(code = 200,
                    message = "Returns information about cluster (Kafka, Zookeeper etc.)",
                    response = ClusterConfigVO.class)
    })
    Response getClusterConfig();
}
